package com.sgl.blog.config;

import com.sgl.blog.interceptor.IndexInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @标题：
 * @内容：
 * @作者： 宋志豪
 */
@Configuration
public class IndexConfig implements WebMvcConfigurer {

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("blog/list").setViewName("blog/list");
        registry.addViewController("user/info").setViewName("user/info");
        registry.addViewController("/").setViewName("blog/list");
        registry.addViewController("index").setViewName("blog/list");
        registry.addViewController("index.html").setViewName("blog/list");
        registry.addViewController("user/pictureUpload").setViewName("user/pictureUpload");
        registry.addViewController("user/changePassword").setViewName("user/changePassword");

    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new IndexInterceptor()).addPathPatterns("/user/login");
    }
}
